package com.xy.demo.service.impl;

import com.github.pagehelper.PageHelper;
import com.xy.demo.Util.ResultUtil;
import com.xy.demo.mapper.mysql.BillMapper;
import com.xy.demo.mapper.mysql.RoleMapper;
import com.xy.demo.model.Bill;
import com.xy.demo.model.Params;
import com.xy.demo.model.ResultInfo;
import com.xy.demo.model.Role;
import com.xy.demo.service.BillService;
import com.xy.demo.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BillServiceImpl implements BillService {

    @Autowired
    private BillMapper billMapper;

    @Override
    public ResultInfo getAll(Params params) {
        if(params.getPageNum()!=null&&params.getPageSize()!=null){
            PageHelper.startPage(params.getPageNum(),params.getPageSize(),true);
        }
        List<Bill> list = billMapper.getAll(params);

//        if(list.size()>0){
//            for(Bill b : list){
//
//            }
//        }
        ResultInfo resultInfo = ResultUtil.getResultInfoOk(list);
        return resultInfo;
    }


    @Override
    public ResultInfo insertOne(Bill bill) {
        billMapper.insertOne(bill);
        return null;
    }
}
